<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>H+ 后台主题UI框架 - 空白页</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="__STATIC__/layout/favicon.ico">
    <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <!-- jqgrid-->
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
</head>
<!---->
<body style="color:#333;padding:3px;">
<!-- 标题 -->
<div class="page-heade">
    <h1 class="title_color">广州销路通软件有限公司-销售发货单</h1>
</div>
<!-- 标题 -->
<div>
    <form action="" class="form-inline" method="get">
        <input name="wllx" type="hidden"   value="{$data.wllx}">
        <div class="padding-10">
            <div class="form-group">
                {$data.khmc}编号：<span>{$data.ckdx_sn}<input type="hidden" name="bh" value="{$data.ckdx_sn}"></span>
            </div>
            <div class="form-group text-left lr_5" style="float: right;">
                NO: <span>{$fhd_sn}</span>
            </div>
        </div>
        <div class="">
            <div class="form-group">
                {$data.khmc}名称：<span>{$data.ckdx_name}<input type="hidden" name="mc" value="{$data.ckdx_name}"></span>；送货地址：<span class="gystext">{$data.shdz}<input type="hidden" name="shdz" value="{$data.shdz}"></span>；联系人：<span>{$data.shlxr}<input type="hidden" name="shlxr" value="{$data.shlxr}"></span>；电话：<span>{$data.shdh}<input type="hidden" name="shdh" value="{$data.shdh}"></span>
            </div>
            <div class="form-group" style="float: right;">
                日期：<input type="text" class="form-control layer-date" name="rq" id="shipmentsDate"  style="min-width: 120px;width: 120px;" value="{:date('Y-m-d')}">
            </div>
        </div>
        <table class="row-margin-top tab-content table-bordered table text-right" border="1">
            <tr class="info">
                <th class="text-center">仓库名称</th>
                <th class="text-center">产品名称</th>
                <th class="text-center">规格</th>
                <th class="text-center">单位</th>
                <th class="text-center">出库数量</th>
                {if $data.yfhsl==1}
                <th class="text-center">已发货数量</th>
                {/if}
                <th class="text-center">销售数量</th>
                <th class="text-center">搭赠数量</th>
                <th class="text-center">箱价</th>
                <th class="text-center">销售金额</th>
                <th class="text-center">搭赠金额</th>
                <th class="text-center">体积(立方米)</th>
                <th class="text-center">重量(吨)</th>
                <th class="text-center">备注</th>
            </tr>
            {volist name="data.list" id="row"}
            <tr>
                <input type="hidden" name="fkdmx_id[{$row.title}]" value="{$row.id}">
                <td class="text-left">{$data.dyck}</td>
                <td class="text-left">{$row.title_name}</td>
                <td class="text-left"></td>
                <td>{$row.unit}</td>
                <td class="text-right"><span>{$row.num}</span></td>
                {if $data.yfhsl==1}
                <td class="text-right"><span>{$row.fhsl}</span></td>
                {/if}
                <td class="text-center"><input type="text" class="form-control" name="xssl[{$row.title}]" style="min-width: 120px;width: 120px;"></td>
                <td class="text-center"><input type="text" class="form-control" name="dzsl[{$row.title}]" style="min-width: 120px;width: 120px;"></td>
                <td><span class="ObjectNum dj">{$row.dj}</span></td>
                <td><span class="ObjectNum xsje"></span></td>
                <td><span class="ObjectNum dzje"></span></td>
                <td><span>{$row.tj}</span></td>
                <td><span>{$row.zl}</span></td>
                <td><input type="text" class="form-control" name="bz[{$row.title}]"></td>
            </tr>
            {/volist}
            <tfoot>
            <tr class="font-bold">
                <td colspan="3" class="text-center">本页合计:</td>
                <td></td>
                <td><span>{$ckslhj}</span></td>
                {if $data.yfhsl==1}
                <td><span>{$yfhslhj}</span></td>
                {/if}
                <td><span id="xssl_hj">0</span></td>
                <td><span id="dzsl_hj">0</span></td>
                <td><span class="ObjectNum"></span></td>
                <td><span class="ObjectNum" id="xsje_hj">0</span></td>
                <td><span class="ObjectNum" id="dzje_hj">0</span></td>
                <td><span>{$tj}</span></td>
                <td><span>{$zl}</span></td>
                <td></td>
            </tr>
            <tr class="font-bold">
                <td colspan="3" class="text-center">实收金额(大写):</td>
                <td colspan="6" id="ChineseMoney">0</td>
                <input type="hidden" name="ssje">
                <td colspan="4" class="text-left">元</td>
            </tr>
            </tfoot>
        </table>
        <div class="padding-10">
            制单人：<span>{$zdr}<input type="hidden" name="zdr" value="{:session('employee_id')}"></span>
            <span class="lr_5"></span><span class="lr_5"></span><label for="">物流公司<span class="colorRed">*</span></label>
            <select name="wlgs" id="wlgs" class="form-control">
                <option value="">请选择</option>
                {volist name="wlgs" id="row"}
                <option value="{$row.id}" data-lxr="{$row.lxr}" data-dh="{$row.dh}">{$row.title}</option>
                {/volist}
            </select>；
            <span id="lxrdh"></span>
            <span class="lr_5"></span>
            物流单号：<input type="text" class="form-control" name="wldh" id="" style="min-width: 140px;width: 140px;"><span class="lr_5"></span>
            预估到货时间：<input type="text" class="form-control layer-date" name="ygdhsj" id="yg_dhDate" style="min-width: 120px;width: 120px;">
        </div>

        <div class="text-center">
            <button class="btn btn-success" type="button" id="qrfh">确认发货</button>
            <button class="btn btn-warning" type="button" id="fanhui">返回</button>
        </div>
    </form>
</div>
<!-- 全局js -->
<script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
<script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
<!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
<script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
<script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="__STATIC__/layout/js/common.js"></script>
<script>
    $('#qrfh').on('click',function () {
        if($('#wlgs').val()==''){
            swal('','请选择物流公司','error')
            return false
        }else{
            var param = $(this).closest('form').serialize()
            $.post('',param,function (data) {
                if(data.success){
                    swal({title:'发货成功'},function () {
                        location.href='{:url("fhgl")}'
                    })
                }else{
                    swal('',data.msg,'error')
                }
            },'json')
        }
        return false
    })
    //销售数量
    $('[name^=xssl]').on('input',function () {
        var xssl_hj = 0;
        $('[name^=xssl]').each(function (i,o) {
            xssl_hj += parseInt($(o).val())
        })
        $('#xssl_hj').html(xssl_hj)
        var xssl = $(this).val()
        var dj = $(this).closest('tr').find('.dj').html()
        var xsje = parseInt(xssl)*parseFloat(dj)
        $(this).closest('tr').find('.xsje').html(xsje)

        var xsje_hj = 0;
        $('.xsje').each(function (i,o) {
            xsje_hj += parseFloat($(o).html())
        })
        $('#xsje_hj').html(xsje_hj)
        $('#ChineseMoney').html(xsje_hj)
        $('[name=ssje]').html(xsje_hj)
    })
    //搭赠数量
    $('[name^=dzsl]').on('input',function () {
        var xssl_hj = 0;
        $('[name^=dzsl]').each(function (i,o) {
            xssl_hj += parseInt($(o).val())
        })
        $('#dzsl_hj').html(xssl_hj)
        var xssl = $(this).val()
        var dj = $(this).closest('tr').find('.dj').html()
        var xsje = parseInt(xssl)*parseFloat(dj)
        $(this).closest('tr').find('.dzje').html(xsje)

        var dzje_hj = 0;
        $('.dzje').each(function (i,o) {
            dzje_hj += parseFloat($(o).html())
        })
        $('#dzje_hj').html(dzje_hj)
    })
    $('#fanhui').on('click',function () {
        location.href='{:url("fhgl")}'
        return false
    })
    //物流公司
    $('#wlgs').on('change',function () {
        if($(this).val()==''){
            $('#lxrdh').html('')
        }else{
            var lxr =  $(this).find('option:selected').data('lxr')
            var dh = $(this).find('option:selected').data('dh')
            $('#lxrdh').html('<input type="hidden" name="lxr" value="'+lxr+'"><input type="hidden" name="dh" value="'+dh+'">联系人：'+lxr+'；电话：'+dh+'；')
        }
    })
    laydate({
        elem: "#shipmentsDate",
        event: "focus"
    })
    laydate({
        elem: "#yg_dhDate",
        event: "focus"
    })

    $(document).ready(function () {
        var $ObjectNum = $(".ObjectNum");
        toNum($ObjectNum);
        var $gysText = $(".gystext");
        var num = 13;
        $gysText.each(function () {
            wordlimit($(this), num)
        })

    })

    function wordlimit(cname, num) {
        for (var i = 0; i < cname.length; i++) {
            var nowLength = cname[i].innerHTML.length;
            if (nowLength > num) {
                return cname[i].innerHTML = cname[i].innerHTML.substr(0, num) + '...'
            }
        }
    }
</script>
<script>
    /*金额转化为大写*/
    var num = $("#num").text()
    // console.log(ChineseMoney)
    Arabia_To_SimplifiedChinese(num);
    var ChineseMoney = $("#ChineseMoney").html(newchar)

    // console.log(num)
    function Arabia_To_SimplifiedChinese(Num) {
        for (i = Num.length - 1; i >= 0; i--) {
            Num = Num.replace(",", "")//替换Num中的“,”
            Num = Num.replace(" ", "")//替换Num中的空格
        }
        if (isNaN(Num)) { //验证输入的字符是否为数字
            //alert("请检查小写金额是否正确");
            return;
        }
        //字符处理完毕后开始转换，采用前后两部分分别转换
        part = String(Num).split(".");
        newchar = "";
        //小数点前进行转化
        for (i = part[0].length - 1; i >= 0; i--) {
            if (part[0].length > 10) {
                //alert("位数过大，无法计算");
                return "";
            }//若数量超过拾亿单位，提示"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"
            tmpnewchar = ""
            perchar = part[0].charAt(i);
            switch (perchar) {
                case "0":
                    tmpnewchar = "零" + tmpnewchar;
                    break;
                case "1":
                    tmpnewchar = "壹" + tmpnewchar;
                    break;
                case "2":
                    tmpnewchar = "贰" + tmpnewchar;
                    break;
                case "3":
                    tmpnewchar = "叁" + tmpnewchar;
                    break;
                case "4":
                    tmpnewchar = "肆" + tmpnewchar;
                    break;
                case "5":
                    tmpnewchar = "伍" + tmpnewchar;
                    break;
                case "6":
                    tmpnewchar = "陆" + tmpnewchar;
                    break;
                case "7":
                    tmpnewchar = "柒" + tmpnewchar;
                    break;
                case "8":
                    tmpnewchar = "捌" + tmpnewchar;
                    break;
                case "9":
                    tmpnewchar = "玖" + tmpnewchar;
                    break;
            }
            switch (part[0].length - i - 1) {
                case 0:
                    tmpnewchar = tmpnewchar;
                    break;
                case 1:
                    if (perchar != 0) tmpnewchar = tmpnewchar + "拾";
                    break;
                case 2:
                    if (perchar != 0) tmpnewchar = tmpnewchar + "佰";
                    break;
                case 3:
                    if (perchar != 0) tmpnewchar = tmpnewchar + "仟";
                    break;
                case 4:
                    tmpnewchar = tmpnewchar + "万";
                    break;
                case 5:
                    if (perchar != 0) tmpnewchar = tmpnewchar + "拾";
                    break;
                case 6:
                    if (perchar != 0) tmpnewchar = tmpnewchar + "佰";
                    break;
                case 7:
                    if (perchar != 0) tmpnewchar = tmpnewchar + "仟";
                    break;
                case 8:
                    tmpnewchar = tmpnewchar + "亿";
                    break;
                case 9:
                    tmpnewchar = tmpnewchar + "拾";
                    break;
            }
            newchar = tmpnewchar + newchar;
        }
        //替换所有无用汉字，直到没有此类无用的数字为止
        while (newchar.search("零零") != -1 || newchar.search("零亿") != -1 || newchar.search("亿万") != -1 || newchar.search("零万") != -1) {
            newchar = newchar.replace("零亿", "亿");
            newchar = newchar.replace("亿万", "亿");
            newchar = newchar.replace("零万", "万");
            newchar = newchar.replace("零零", "零");
        }
        //替换以“一十”开头的，为“十”
        if (newchar.indexOf("一十") == 0) {
            newchar = newchar.substr(1);
        }
        //替换以“零”结尾的，为“”
        if (newchar.lastIndexOf("零") == newchar.length - 1) {
            newchar = newchar.substr(0, newchar.length - 1);
        }
        console.log(newchar)
        return newchar;

    }
</script>
</body>

</html>
